package cn.laixueit.controller;

import cn.laixueit.pojo.Address;
import cn.laixueit.pojo.User;
import cn.laixueit.result.Result;
import cn.laixueit.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.List;

@RestController
@RequestMapping("/address")
public class AddressController {

    @Autowired
    private AddressService addressService;

    @GetMapping("/findAll")
    public Result findAll(HttpSession session){
        User user = (User) session.getAttribute("u");
        Integer uid = user.getId();
        List<Address> addressList = addressService.findAll(uid);
        return new Result(200,addressList);
    }
}
